/*
 * Copyright (c) 2011 Norbert Kopcsek
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */
package org.modulr.bundle {

	import mx.collections.IList;

	import org.modulr.feature.Feature;
	import org.modulr.framework.Framework;
	import org.modulr.service.IServiceListener;
	import org.modulr.service.IServiceReference;
	import org.modulr.service.IServiceRegistration;

	/**
	 * The Framework is the only entity that can create BundleContext objects and they are only valid within the Framework that created them.
	 * @see org.modulr.bundle.Bundle
	 * @see org.modulr.framework.Framework
	 * @author Norbert Kopcsek
	 */
    // TODO Enforce that only the framework can create bundle contexts!
	public interface IBundleContext {

		function get bundle():Bundle;

		function get framework():Framework;

		//function get servicesInUse():IList;
		//function set servicesInUse( value:IList ):void

		function addBundleListener( listener:IBundleListener ):void;
		function removeBundleListener( listener:IBundleListener ):void;
		function addServiceListener( listener:IServiceListener ):void;
		function removeServiceListener( listener:IServiceListener ):void;

		function getBundleById( id:String ):Bundle;
		function activateBundle( bundle:Bundle ):void;

		function registerService( clazz:String, service:Object, properties:Object = null ):IServiceRegistration;
		//function unregisterService( registration:IServiceRegistration ):void;
		//function unregisterServices():void;

		function getServiceReference( clazz:String ):IServiceReference;
		function getServiceReferences( clazz:String ):IList;

		function getService( reference:IServiceReference ):Object;
		function ungetService( reference:IServiceReference ):Boolean;
	}
}

